/*
 *  Acronym                : TrmIic.h
 *  Name of Module         : TrmIic.a
 *  Product/Project        : Rhapsody for TriMedia
 *  12NC                   :
 *  Group number           : 885540
 *  Creation date          : 1999-03-17
 *  Modification date      : 1999-03-17
 *  Related documents      : CTB554-98-B155
 *  Program language       : C
 *  Documentation language : English
 *  Status                 : Preliminary
 *  Author(s)              : P.J. Zander
 *
 *                Copyright (C) Philips Electronics N.V. 1999
 *                  CFT Centre for Manufacturing Technology
 *                        Eindhoven - The Netherlands
 *
 *       All rights are reserved. Reproduction in whole or in part is
 *           prohibited without the written consent of the author.
 */

/*
 *  Description:	
 *    Export header file of Subsystem: Iic
 *
 */

#ifndef _TRMIIC_H
#define _TRMIIC_H

/*
 *----------------------------------------------------------------------------
 *  System Includes
 *----------------------------------------------------------------------------
 */

#include <tm1\mmio.h>
#include <tm1\tmIICmmio.h>

/*
 *----------------------------------------------------------------------------
 * C++ Define
 *----------------------------------------------------------------------------
 */

#ifdef __cplusplus
extern "C" {
#endif

/*
 *----------------------------------------------------------------------------
 * Exported Defines
 *----------------------------------------------------------------------------
 */

#define TRM_IIC_GDI_DISABLE           0
#define TRM_IIC_GDI_ENABLE            1

#define TRM_IIC_FI_DISABLE            0
#define TRM_IIC_FI_ENABLE             1

#define TRM_IIC_SANACKI_DISABLE       0
#define TRM_IIC_SANACKI_ENABLE        1

#define TRM_IIC_SDNACKI_DISABLE       0
#define TRM_IIC_SDNACKI_ENABLE        1

#define TRM_IIC_READ                  (1u<<24)
#define TRM_IIC_COUNT_SHIFT           8
#define TRM_IIC_ADDRESS_SHIFT        24

#define TRM_IIC_GDI                   IIC_GDI
#define TRM_IIC_FI                    IIC_FI
#define TRM_IIC_SANACKI               IIC_SANACKI
#define TRM_IIC_SDNACKI               IIC_DANACKI

/*
 *----------------------------------------------------------------------------
 * Exported Macros
 *----------------------------------------------------------------------------
 */

#define TrmIicSetAR(x)   (MMIO(IIC_AR)=(x))
#define TrmIicGetDR()    (MMIO(IIC_DR))
#define TrmIicSetDR(x)   (MMIO(IIC_DR)=(x))
#define TrmIicGetSR()    (MMIO(IIC_STATUS))
#define TrmIicSetCR(x)   (MMIO(IIC_CTL)=(x))

#define TrmIicClear()    (MMIO(IIC_CTL)|=(0x03C00000))

/*
 *----------------------------------------------------------------------------
 * Exported Function Prototypes
 *----------------------------------------------------------------------------
 */

    void TrmIicOpen(
      void);
    
    void TrmIicIsr(
      void (*fIsr)(void),
      int    priority,
      int    gdi,
      int    fi,
      int    sanacki,
      int    sdnacki);

/*
 *----------------------------------------------------------------------------
 */

#ifdef __cplusplus
}
#endif

#endif
